package com.csdj.rest.controller;

import com.csdj.beans.entity.Menu;
import com.csdj.common.annnation.Roles;
import com.csdj.rest.service.MenuService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Controller
public class IndexController {

    @Resource
    private MenuService menuService;



    @Roles(value="admin")
    @GetMapping("/index")
    public ModelAndView index(){
        final ModelAndView view = new ModelAndView();
        view.addObject("name","world");
        view.setViewName("index");
        view.addObject("list",Arrays.asList("one","two","three","four","five"));
        view.addObject("menus",menuService.getMenus("admin"));
        return view;
    }







}
